/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package pruebascarga;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import java.sql.Timestamp;
import java.util.Date;
import java.util.Random;
import java.util.Scanner;

/**
 *
 * @author narf
 */
public class PruebasCarga {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        System.out.println("Ingrese la cantidada de pymes: ");
        Scanner input = new Scanner(System.in);
        String answer = input.nextLine();

        int tam = Integer.parseInt(answer);
        Connection c = null;
        Statement stmt = null;
        try {
            Class.forName("org.postgresql.Driver");
            c = DriverManager
                    .getConnection("jdbc:postgresql://localhost:5432/SCLOUD",
                            "postgres", "admin");
            c.setAutoCommit(false);
            System.out.println("Coonexion establecida");
            stmt = c.createStatement();

            long start = System.currentTimeMillis();
            System.out.println("Crecion Pymes");
            for (int i = 1; i <= tam; i++) {
                String sql = "INSERT INTO \"javeriana.sc.cc\".\"t_pyme\" (\"identification\",\"name\",\"address\") VALUES (" + i + ",'pyme" + i + "','Direccion " + i + "');";
                stmt.executeUpdate(sql);
            }

            long elapsedTimeMillis = System.currentTimeMillis() - start;
            System.out.println("Tiempo creando Pymes:" + (elapsedTimeMillis / 1000F) + " segundos.");

            System.out.println("Creacion t_material");

            String sql = "INSERT INTO \"javeriana.sc.cc\".\"t_material\" (\"typematerial\") VALUES ('Cordon');";
            stmt.executeUpdate(sql);
            sql = "INSERT INTO \"javeriana.sc.cc\".\"t_material\" (\"typematerial\") VALUES ('Fierro');";
            stmt.executeUpdate(sql);
            sql = "INSERT INTO \"javeriana.sc.cc\".\"t_material\" (\"typematerial\") VALUES ('Pegante');";
            stmt.executeUpdate(sql);
            sql = "INSERT INTO \"javeriana.sc.cc\".\"t_material\" (\"typematerial\") VALUES ('Planta');";
            stmt.executeUpdate(sql);
            sql = "INSERT INTO \"javeriana.sc.cc\".\"t_material\" (\"typematerial\") VALUES ('Cuero');";
            stmt.executeUpdate(sql);
            sql = "INSERT INTO \"javeriana.sc.cc\".\"t_material\" (\"typematerial\") VALUES ('Textil');";
            stmt.executeUpdate(sql);
            sql = "INSERT INTO \"javeriana.sc.cc\".\"t_material\" (\"typematerial\") VALUES ('Hule');";
            stmt.executeUpdate(sql);
            sql = "INSERT INTO \"javeriana.sc.cc\".\"t_material\" (\"typematerial\") VALUES ('Cremallera');";
            stmt.executeUpdate(sql);
            sql = "INSERT INTO \"javeriana.sc.cc\".\"t_material\" (\"typematerial\") VALUES ('Estampado');";
            stmt.executeUpdate(sql);
            sql = "INSERT INTO \"javeriana.sc.cc\".\"t_material\" (\"typematerial\") VALUES ('Plastico');";
            stmt.executeUpdate(sql);
            sql = "INSERT INTO \"javeriana.sc.cc\".\"t_material\" (\"typematerial\") VALUES ('Quimico');";
            stmt.executeUpdate(sql);

            System.out.println("Ingrese numero de parejas de producto por pyme: ");

            String pr = input.nextLine();

            int tamProd = Integer.parseInt(pr);
            int cantidadProd = 19 * tamProd;
            start = System.currentTimeMillis();
            System.out.println("Creacion t_product");
            int finp = cantidadProd * tam;
            int p = 1;
            int tamp = 1;
            int cp = 1;
            while (p <= finp) {

                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_product\" (\"idproduct\",\"pymeidentification\",\"name\",\"price\",\"quantity\",\"capacity\",\"productionabledate\",\"tosell\",\"howmanythisday\",\"productiontime\",\"material\") VALUES (" + p + "," + tamp + ",'cordones " + p + "',2,0,0,'2012-11-20 00:00:00',0,1,2, 'Cordon');";//hijo
                stmt.executeUpdate(sql);
                p++;
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_product\" (\"idproduct\",\"pymeidentification\",\"name\",\"price\",\"quantity\",\"capacity\",\"productionabledate\",\"tosell\",\"howmanythisday\",\"productiontime\",\"material\") VALUES (" + p + "," + tamp + ",'superficie " + p + "',1,0,2,'2012-11-20 00:00:00',0,1,2,null);";
                stmt.executeUpdate(sql);
                p++;
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_product\" (\"idproduct\",\"pymeidentification\",\"name\",\"price\",\"quantity\",\"capacity\",\"productionabledate\",\"tosell\",\"howmanythisday\",\"productiontime\",\"material\") VALUES (" + p + "," + tamp + ",'suela " + p + "',1,0,2,'2012-11-20 00:00:00',0,1,2,null);";
                stmt.executeUpdate(sql);
                p++;
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_product\" (\"idproduct\",\"pymeidentification\",\"name\",\"price\",\"quantity\",\"capacity\",\"productionabledate\",\"tosell\",\"howmanythisday\",\"productiontime\",\"material\") VALUES (" + p + "," + tamp + ",'puntilla " + p + "',0,0,2,'2012-11-20 00:00:00',0,1,0,'Fierro');";//hijo
                stmt.executeUpdate(sql);
                p++;
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_product\" (\"idproduct\",\"pymeidentification\",\"name\",\"price\",\"quantity\",\"capacity\",\"productionabledate\",\"tosell\",\"howmanythisday\",\"productiontime\",\"material\") VALUES (" + p + "," + tamp + ",'taches " + p + "',0,0,2,'2012-11-20 00:00:00',0,1,0,'Fierro');";//hijo
                stmt.executeUpdate(sql);
                p++;
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_product\" (\"idproduct\",\"pymeidentification\",\"name\",\"price\",\"quantity\",\"capacity\",\"productionabledate\",\"tosell\",\"howmanythisday\",\"productiontime\",\"material\") VALUES (" + p + "," + tamp + ",'cuero1 " + p + "',1,10,2,'2012-11-20 00:00:00',0,1,2,null);";
                stmt.executeUpdate(sql);
                p++;
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_product\" (\"idproduct\",\"pymeidentification\",\"name\",\"price\",\"quantity\",\"capacity\",\"productionabledate\",\"tosell\",\"howmanythisday\",\"productiontime\",\"material\") VALUES (" + p + "," + tamp + ",'cola " + p + "',1,0,2,'2012-11-20 00:00:00',0,1,0.01,'Pegante');";//hijo
                stmt.executeUpdate(sql);
                p++;
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_product\" (\"idproduct\",\"pymeidentification\",\"name\",\"price\",\"quantity\",\"capacity\",\"productionabledate\",\"tosell\",\"howmanythisday\",\"productiontime\",\"material\") VALUES (" + p + "," + tamp + ",'planta " + p + "',1,0,2,'2012-11-20 00:00:00',0,1,1,'Planta');";//hijo
                stmt.executeUpdate(sql);
                p++;
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_product\" (\"idproduct\",\"pymeidentification\",\"name\",\"price\",\"quantity\",\"capacity\",\"productionabledate\",\"tosell\",\"howmanythisday\",\"productiontime\",\"material\") VALUES (" + p + "," + tamp + ",'tacon " + p + "',1,0,2,'2012-11-20 00:00:00',0,1,1,null);";
                stmt.executeUpdate(sql);
                p++;
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_product\" (\"idproduct\",\"pymeidentification\",\"name\",\"price\",\"quantity\",\"capacity\",\"productionabledate\",\"tosell\",\"howmanythisday\",\"productiontime\",\"material\") VALUES (" + p + "," + tamp + ",'cuero " + p + "',1,0,2,'2012-11-20 00:00:00',0,1,0.25,'Cuero');";//hijo
                stmt.executeUpdate(sql);
                p++;
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_product\" (\"idproduct\",\"pymeidentification\",\"name\",\"price\",\"quantity\",\"capacity\",\"productionabledate\",\"tosell\",\"howmanythisday\",\"productiontime\",\"material\") VALUES (" + p + "," + tamp + ",'hilo " + p + "',0,10,2,'2012-11-20 00:00:00',0,1,0.1,'Textil');";//hijo
                stmt.executeUpdate(sql);
                p++;
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_product\" (\"idproduct\",\"pymeidentification\",\"name\",\"price\",\"quantity\",\"capacity\",\"productionabledate\",\"tosell\",\"howmanythisday\",\"productiontime\",\"material\") VALUES (" + p + "," + tamp + ",'caucho " + p + "',1,20,2,'2012-11-20 00:00:00',0,1,5,'Hule');";//hijo
                stmt.executeUpdate(sql);
                p++;
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_product\" (\"idproduct\",\"pymeidentification\",\"name\",\"price\",\"quantity\",\"capacity\",\"productionabledate\",\"tosell\",\"howmanythisday\",\"productiontime\",\"material\") VALUES (" + p + "," + tamp + ",'zapato " + p + "',3,0,2,'2013-10-29 00:00:00',1,1,3,null);";
                stmt.executeUpdate(sql);
                p++;
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_product\" (\"idproduct\",\"pymeidentification\",\"name\",\"price\",\"quantity\",\"capacity\",\"productionabledate\",\"tosell\",\"howmanythisday\",\"productiontime\",\"material\") VALUES (" + p + "," + tamp + ",'maleta " + p + "',1,2,2,'2015-03-11 00:00:00',1,1,1,null);";
                stmt.executeUpdate(sql);
                p++;
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_product\" (\"idproduct\",\"pymeidentification\",\"name\",\"price\",\"quantity\",\"capacity\",\"productionabledate\",\"tosell\",\"howmanythisday\",\"productiontime\",\"material\") VALUES (" + p + "," + tamp + ",'etiquetado " + p + "',3,0,2,'2015-03-06 00:00:00',0,1,2,null);";
                stmt.executeUpdate(sql);
                p++;
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_product\" (\"idproduct\",\"pymeidentification\",\"name\",\"price\",\"quantity\",\"capacity\",\"productionabledate\",\"tosell\",\"howmanythisday\",\"productiontime\",\"material\") VALUES (" + p + "," + tamp + ",'cremallera " + p + "',2,0,2,'2015-02-14 00:00:00',0,1,2,'Cremallera');";//hijo
                stmt.executeUpdate(sql);
                p++;
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_product\" (\"idproduct\",\"pymeidentification\",\"name\",\"price\",\"quantity\",\"capacity\",\"productionabledate\",\"tosell\",\"howmanythisday\",\"productiontime\",\"material\") VALUES (" + p + "," + tamp + ",'superficie2 " + p + "',3,0,2,'2015-02-14 00:00:00',0,1,3,null);";
                stmt.executeUpdate(sql);
                p++;
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_product\" (\"idproduct\",\"pymeidentification\",\"name\",\"price\",\"quantity\",\"capacity\",\"productionabledate\",\"tosell\",\"howmanythisday\",\"productiontime\",\"material\") VALUES (" + p + "," + tamp + ",'planchado " + p + "',1,0,2,'2015-02-12 00:00:00',0,1,1,null);";
                stmt.executeUpdate(sql);
                p++;
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_product\" (\"idproduct\",\"pymeidentification\",\"name\",\"price\",\"quantity\",\"capacity\",\"productionabledate\",\"tosell\",\"howmanythisday\",\"productiontime\",\"material\") VALUES (" + p + "," + tamp + ",'imagen " + p + "',3,0,2,'2015-02-11 00:00:00',0,1,0,'Estampado');";//hijo
                stmt.executeUpdate(sql);
                p++;
                if (cp < tamProd) {
                    cp++;
                } else {
                    cp = 1;
                    tamp++;
                }

            }
            elapsedTimeMillis = System.currentTimeMillis() - start;
            System.out.println("Tiempo creando t_product:" + (elapsedTimeMillis / 1000F) + " segundos.");

            System.out.println("Creacion t_productstructure");
            start = System.currentTimeMillis();
            finp = cantidadProd * tam;
            p = 1;
            tamp = 1;

            while (p <= finp) {
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_productstructure\" (\"productid\",\"productidc\",\"quantityrequired\") VALUES (" + p + "," + (p + 12) + ",2);";
                stmt.executeUpdate(sql);
                p++;
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_productstructure\" (\"productid\",\"productidc\",\"quantityrequired\") VALUES (" + p + "," + (p + 11) + ",1);";
                stmt.executeUpdate(sql);
                p++;
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_productstructure\" (\"productid\",\"productidc\",\"quantityrequired\") VALUES (" + p + "," + (p + 10) + ",1);";
                stmt.executeUpdate(sql);
                p++;
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_productstructure\" (\"productid\",\"productidc\",\"quantityrequired\") VALUES (" + p + "," + (p - 2) + ",5);";
                stmt.executeUpdate(sql);
                //4
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_productstructure\" (\"productid\",\"productidc\",\"quantityrequired\") VALUES (" + p + "," + (p + 5) + ",4);";
                stmt.executeUpdate(sql);
                p++;
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_productstructure\" (\"productid\",\"productidc\",\"quantityrequired\") VALUES (" + p + "," + (p - 3) + ",8);";
                stmt.executeUpdate(sql);
                p++;//6
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_productstructure\" (\"productid\",\"productidc\",\"quantityrequired\") VALUES (" + p + "," + (p - 4) + ",1);";
                stmt.executeUpdate(sql);

                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_productstructure\" (\"productid\",\"productidc\",\"quantityrequired\") VALUES (" + p + "," + (p + 11) + ",3);";
                stmt.executeUpdate(sql);
                p++;
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_productstructure\" (\"productid\",\"productidc\",\"quantityrequired\") VALUES (" + p + "," + (p - 4) + ",0.1);";
                stmt.executeUpdate(sql);
                p++;//8
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_productstructure\" (\"productid\",\"productidc\",\"quantityrequired\") VALUES (" + p + "," + (p - 5) + ",1);";
                stmt.executeUpdate(sql);
                p++;
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_productstructure\" (\"productid\",\"productidc\",\"quantityrequired\") VALUES (" + p + "," + (p - 6) + ",1);";
                stmt.executeUpdate(sql);
                p++;//10
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_productstructure\" (\"productid\",\"productidc\",\"quantityrequired\") VALUES (" + p + "," + (p - 4) + ",0.25);";
                stmt.executeUpdate(sql);
                p++;
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_productstructure\" (\"productid\",\"productidc\",\"quantityrequired\") VALUES (" + p + "," + (p - 5) + ",0.1);";
                stmt.executeUpdate(sql);
                p++;//12
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_productstructure\" (\"productid\",\"productidc\",\"quantityrequired\") VALUES (" + p + "," + (p - 3) + ",5);";
                stmt.executeUpdate(sql);

                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_productstructure\" (\"productid\",\"productidc\",\"quantityrequired\") VALUES (" + p + "," + (p + 6) + ",2);";
                stmt.executeUpdate(sql);
                p++;
                p++;
                p++;

                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_productstructure\" (\"productid\",\"productidc\",\"quantityrequired\") VALUES (" + p + "," + (p - 1) + ",3);";
                stmt.executeUpdate(sql);
                p++;//16
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_productstructure\" (\"productid\",\"productidc\",\"quantityrequired\") VALUES (" + p + "," + (p - 2) + ",2);";
                stmt.executeUpdate(sql);
                p++;
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_productstructure\" (\"productid\",\"productidc\",\"quantityrequired\") VALUES (" + p + "," + (p - 3) + ",1);";
                stmt.executeUpdate(sql);
                p++;
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_productstructure\" (\"productid\",\"productidc\",\"quantityrequired\") VALUES (" + p + "," + (p - 3) + ",1);";
                stmt.executeUpdate(sql);
                p++;
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_productstructure\" (\"productid\",\"productidc\",\"quantityrequired\") VALUES (" + p + "," + (p - 1) + ",0);";
                stmt.executeUpdate(sql);
                p++;
//                System.out.println("p: " + p);
            }

            elapsedTimeMillis = System.currentTimeMillis() - start;
            System.out.println("Tiempo creando t_productstructure:" + (elapsedTimeMillis / 1000F) + " segundos.");

            System.out.println("Creacion t_supplier");

            sql = "INSERT INTO \"javeriana.sc.cc\".\"t_supplier\" (\"identification\",\"name\",\"address\",\"phone\",\"email\",\"material\") VALUES (1,'Proveedor de Cordones 1','cll_falsa','123456','carfracor@gmail.com','Cordon');";
            stmt.executeUpdate(sql);
            sql = "INSERT INTO \"javeriana.sc.cc\".\"t_supplier\" (\"identification\",\"name\",\"address\",\"phone\",\"email\",\"material\") VALUES (2,'Proveedor de Cordones 2','cll_falsa','1234567','cfc603@gmail.com','Cordon');";
            stmt.executeUpdate(sql);
            sql = "INSERT INTO \"javeriana.sc.cc\".\"t_supplier\" (\"identification\",\"name\",\"address\",\"phone\",\"email\",\"material\") VALUES (3,'Proveedor de Cordones 3','cll_falsa','123456','frun91@hotmail.com','Cordon');";
            stmt.executeUpdate(sql);
            sql = "INSERT INTO \"javeriana.sc.cc\".\"t_supplier\" (\"identification\",\"name\",\"address\",\"phone\",\"email\",\"material\") VALUES (4,'Proveedor de Fierros','cll_falsa','1234567','cfc603@hotmail.com','Fierro');";
            stmt.executeUpdate(sql);
            sql = "INSERT INTO \"javeriana.sc.cc\".\"t_supplier\" (\"identification\",\"name\",\"address\",\"phone\",\"email\",\"material\") VALUES (5,'Provedeor de Pegantes','cll_falsa','123456','corzoc@javeriana.edu.co','Pegante');";
            stmt.executeUpdate(sql);
            sql = "INSERT INTO \"javeriana.sc.cc\".\"t_supplier\" (\"identification\",\"name\",\"address\",\"phone\",\"email\",\"material\") VALUES (6,'Proveedor de Plantas','cll_falsa','1234567','corzoycastaneda@gmail.com','Planta');";
            stmt.executeUpdate(sql);
            sql = "INSERT INTO \"javeriana.sc.cc\".\"t_supplier\" (\"identification\",\"name\",\"address\",\"phone\",\"email\",\"material\") VALUES (7,'Proveedor de Cueros','cll_falsa','123456','murciajuan@gmail.com','Cuero');";
            stmt.executeUpdate(sql);
            sql = "INSERT INTO \"javeriana.sc.cc\".\"t_supplier\" (\"identification\",\"name\",\"address\",\"phone\",\"email\",\"material\") VALUES (8,'Proveedor de Textiles 1','cll_falsa','1234567','juan.murcia@javeriana.edu.co','Textil');";
            stmt.executeUpdate(sql);
            sql = "INSERT INTO \"javeriana.sc.cc\".\"t_supplier\" (\"identification\",\"name\",\"address\",\"phone\",\"email\",\"material\") VALUES (9,'Proveedor de Hules','cll_falsa','123456','scloudpyme1@gmail.com','Hule');";
            stmt.executeUpdate(sql);
            sql = "INSERT INTO \"javeriana.sc.cc\".\"t_supplier\" (\"identification\",\"name\",\"address\",\"phone\",\"email\",\"material\") VALUES (10,'Proveedor de Textiles 2','cll_falsa','1234567','scloudpyme2@gmail.com','Textil');";
            stmt.executeUpdate(sql);
            sql = "INSERT INTO \"javeriana.sc.cc\".\"t_supplier\" (\"identification\",\"name\",\"address\",\"phone\",\"email\",\"material\") VALUES (11,'Proveedor de Cremalleras','cll_falsa','123456','scloudpyme3@gmail.com','Cremallera');";
            stmt.executeUpdate(sql);
            sql = "INSERT INTO \"javeriana.sc.cc\".\"t_supplier\" (\"identification\",\"name\",\"address\",\"phone\",\"email\",\"material\") VALUES (12,'Proveedor de Estampados','cll_falsa','1234567','margie-14@hotmail.com','Estampado');";
            stmt.executeUpdate(sql);
            sql = "INSERT INTO \"javeriana.sc.cc\".\"t_supplier\" (\"identification\",\"name\",\"address\",\"phone\",\"email\",\"material\") VALUES (13,'Proveedor de Plasticos','cll_falsa','123456','marlucasta@yahoo.com','Plastico');";
            stmt.executeUpdate(sql);
            sql = "INSERT INTO \"javeriana.sc.cc\".\"t_supplier\" (\"identification\",\"name\",\"address\",\"phone\",\"email\",\"material\") VALUES (14,'Proveedor de Quimicos','cll_falsa','1234567','evaristocorzot@gmail.com','Quimico');";
            stmt.executeUpdate(sql);

            System.out.println("Creacion t_emailPyme");
            for (int i = 1; i <= tam; i++) {
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_emailPyme\" (\"idemail\",\"pymeidentification\",\"host\",\"port\", \"username\", \"password\") VALUES (" + i + "," + i + ",'smtp.gmail.com','465','scloudpyme1@gmail.com','scloudmtpyme1');";
                stmt.executeUpdate(sql);
//                System.out.println("Correo pyme: " + i);
            }

            System.out.println("Creacion t_supplierXproduct");
            finp = 19 * tam;
            p = 1;
            tamp = 1;
            while (p <= finp) {

                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_supplierXproduct\" (\"supplierindentification\",\"productid\",\"responsetime\",\"price\",\"lote\") VALUES(1," + p + ", 2, 20, 10);";
                stmt.executeUpdate(sql);

                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_supplierXproduct\" (\"supplierindentification\",\"productid\",\"responsetime\",\"price\",\"lote\") VALUES(2," + p + ", 2, 20, 10);";
                stmt.executeUpdate(sql);

                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_supplierXproduct\" (\"supplierindentification\",\"productid\",\"responsetime\",\"price\",\"lote\") VALUES(3," + p + ", 2, 20, 10);";
                stmt.executeUpdate(sql);
                p = p + 3;
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_supplierXproduct\" (\"supplierindentification\",\"productid\",\"responsetime\",\"price\",\"lote\") VALUES(4," + p + ", 0, 10, 10);";
                stmt.executeUpdate(sql);
                p++;
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_supplierXproduct\" (\"supplierindentification\",\"productid\",\"responsetime\",\"price\",\"lote\") VALUES(4," + p + ", 0, 10, 10);";
                stmt.executeUpdate(sql);
                p = p + 2;
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_supplierXproduct\" (\"supplierindentification\",\"productid\",\"responsetime\",\"price\",\"lote\") VALUES(5," + p + ", 0, 10, 10);";
                stmt.executeUpdate(sql);
                p++;
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_supplierXproduct\" (\"supplierindentification\",\"productid\",\"responsetime\",\"price\",\"lote\") VALUES(6," + p + ", 1, 10, 10);";
                stmt.executeUpdate(sql);
                p = p + 2;
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_supplierXproduct\" (\"supplierindentification\",\"productid\",\"responsetime\",\"price\",\"lote\") VALUES(7," + p + ", 2, 10, 10);";
                stmt.executeUpdate(sql);
                p++;
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_supplierXproduct\" (\"supplierindentification\",\"productid\",\"responsetime\",\"price\",\"lote\") VALUES(8," + p + ", 0, 10, 10);";
                stmt.executeUpdate(sql);

                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_supplierXproduct\" (\"supplierindentification\",\"productid\",\"responsetime\",\"price\",\"lote\") VALUES(10," + p + ", 0, 10, 10);";
                stmt.executeUpdate(sql);
                p++;
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_supplierXproduct\" (\"supplierindentification\",\"productid\",\"responsetime\",\"price\",\"lote\") VALUES(9," + p + ", 1, 10, 10);";
                stmt.executeUpdate(sql);
                p = p + 4;
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_supplierXproduct\" (\"supplierindentification\",\"productid\",\"responsetime\",\"price\",\"lote\") VALUES(11," + p + ", 2, 10, 10);";
                stmt.executeUpdate(sql);
                p = p + 3;
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_supplierXproduct\" (\"supplierindentification\",\"productid\",\"responsetime\",\"price\",\"lote\") VALUES(12," + p + ", 0, 10, 10);";
                stmt.executeUpdate(sql);
                p++;
            }

            System.out.println("Creacion t_emailPyme");
            for (int i = 1; i <= tam; i++) {
                for (int j = 1; j <= 12; j++) {
                    sql = "INSERT INTO \"javeriana.sc.cc\".\"t_supplierXpyme\"(\"pymeidentification\", \"supplierindentification\") VALUES (" + i + "," + j + ");";
                    stmt.executeUpdate(sql);
//                    System.out.println(i+"-"+j);
                }
            }

            System.out.println("Creacion t_supplierXmaterial");
            for (int i = 1; i <= tam; i++) {
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_supplierXmaterial\"(\"typematerial\", \"pymeindentification\", \"supplierindentification\") VALUES ('Cordon'," + i + ", 3);";
                stmt.executeUpdate(sql);
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_supplierXmaterial\"(\"typematerial\", \"pymeindentification\", \"supplierindentification\") VALUES ('Fierro', " + i + ", 4);";
                stmt.executeUpdate(sql);
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_supplierXmaterial\"(\"typematerial\", \"pymeindentification\", \"supplierindentification\") VALUES ('Pegante', " + i + ", 5);";
                stmt.executeUpdate(sql);
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_supplierXmaterial\"(\"typematerial\", \"pymeindentification\", \"supplierindentification\") VALUES ('Planta', " + i + ", 6);";
                stmt.executeUpdate(sql);
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_supplierXmaterial\"(\"typematerial\", \"pymeindentification\", \"supplierindentification\") VALUES ('Cuero', " + i + ", 7);";
                stmt.executeUpdate(sql);
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_supplierXmaterial\"(\"typematerial\", \"pymeindentification\", \"supplierindentification\") VALUES ('Textil', " + i + ", 10);";
                stmt.executeUpdate(sql);
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_supplierXmaterial\"(\"typematerial\", \"pymeindentification\", \"supplierindentification\") VALUES ('Hule', " + i + ", 9);";
                stmt.executeUpdate(sql);
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_supplierXmaterial\"(\"typematerial\", \"pymeindentification\", \"supplierindentification\") VALUES ('Cremallera', " + i + ", 11);";
                stmt.executeUpdate(sql);
                sql = "INSERT INTO \"javeriana.sc.cc\".\"t_supplierXmaterial\"(\"typematerial\", \"pymeindentification\", \"supplierindentification\") VALUES ('Estampado', " + i + ", 12);";
                stmt.executeUpdate(sql);
            }

            System.out.println("Creacion t_nonWorkingDay");

            for (int i = 1; i <= tam; i++) {

                for (int j = 0; j < 30; j++) {
                    try {
                        Date randomDate = new Date(getRandomTimeBetweenTwoDates());
                        sql = "INSERT INTO \"javeriana.sc.cc\".\"t_nonWorkingDay\"(day, month, pymeidentification, year) SELECT " + randomDate.getDate() + ", " + (randomDate.getMonth() + 1) + "," + i + ", " + randomDate.getYear() + " WHERE NOT EXISTS (SELECT 1 from \"javeriana.sc.cc\".\"t_nonWorkingDay\" where \"day\" =" + randomDate.getDate() + " and \"month\" = " + (randomDate.getMonth() + 1) + " and \"year\" = " + randomDate.getYear() + "and pymeidentification = " + i + ");";
                        stmt.executeUpdate(sql);
//                        System.out.println(randomDate);
                    } catch (Exception e) {
                        System.out.println("Fecha repetida para pyme " + i + " Error: " + e.getMessage());
                    }

                }
            }
            stmt.close();
            c.commit();
            c.close();
        } catch (Exception e) {
            System.err.println("Errores : " + e.getClass().getName() + ": " + e.getMessage());
            System.exit(0);
        }
        System.out.println("Creacion finalizada");
    }

    private static long getRandomTimeBetweenTwoDates() {

        long beginTime = Timestamp.valueOf("2014-01-01 00:00:00").getTime();
        long endTime = Timestamp.valueOf("2025-12-31 00:00:00").getTime();
        long diff = endTime - beginTime + 1;

        return beginTime + (long) (Math.random() * diff);
    }

}
